package com.examples.traversal;

import org.eclipse.swt.SWT;
import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.Shell;
import org.eclipse.swt.widgets.TabFolder;
import org.eclipse.swt.widgets.TabItem;

public class PreventingTabTraversal {

	/**
	 * @param args
	 */
	public static void main(String[] args) {

		/* Creating a Display */
		Display display = new Display();

		/* Adding a Shell in the Display */
		Shell shell = new Shell(display);
		shell.setText("Shell");

		/* Creating a tab folder */
		TabFolder tabFolder1 = new TabFolder(shell, SWT.BORDER);
		tabFolder1.pack();
		tabFolder1.setSize(200, 200);

		/* Creating a tab item in the Tab folder 1 */
		TabItem tabItem1 = new TabItem(tabFolder1, SWT.BORDER);
		tabItem1.setText("Item 1");
		
		/* Adding the Traversal Listener */
		TraversalListener traversalListener = new TraversalListener();
		tabFolder1.addTraverseListener(traversalListener);

		/* Setting the preferred size of the shell */
		shell.pack();

		/* Opening the shell */
		shell.open();

		while (!shell.isDisposed()) {
			if (!display.readAndDispatch())
				display.sleep();
		}
		display.dispose();
	}

}
